package com.ruolin.micro.gateway.guide.producer;

import com.ruolin.micro.gateway.guide.api.EchoService;
import com.ruolin.micro.gateway.guide.impl.EchoServiceImpl;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.MetadataReportConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;

public class DubboProvider {

//    public static void main(String[] args) throws InterruptedException {
//
//        ServiceConfig<EchoService> service = new ServiceConfig<>();
//
//        service.setApplication(new ApplicationConfig("dubbo-example-provider"));
//        service.setRegistry(new RegistryConfig("nacos://218.78.55.64:8848"));
//        service.setInterface(EchoService.class);
//        service.setRef(new EchoServiceImpl());
//        service.setVersion("1.0");
//        MetadataReportConfig mrc = new MetadataReportConfig("nacos://218.78.55.64:8848");
//        Map<String, String> parameter = new LinkedHashMap<>();
//        //parameter.put("route_prefix", "/provider/");
//        service.setParameters(parameter);
//        service.setMetadataReportConfig(mrc);
//        service.setGroup("myGroup");
//        service.export();
//        System.out.println("dubbo service started");
//        new CountDownLatch(1).await();
//    }

}
